/**
 * Copyright (c) 2010 Sense Tecnic Systems Inc.
 */
package com.testcase.vincentApp;

import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.util.Log;

/**
 * Callback class to handle the event where Android provides an update for the
 * user's current location. This listener just saves the last known location to
 * be read at a later date.
 * 
 * @author Vincent Tsao
 */
class LocationUpdateHandler implements LocationListener
{
	private Location lastKnownLocation;

	/**
	 * Constructor to create a new instance of a location update handler.
	 */
	LocationUpdateHandler ()
	{
		lastKnownLocation = null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * android.location.LocationListener#onLocationChanged(android.location.
	 * Location)
	 */
	public void onLocationChanged (Location location)
	{
		lastKnownLocation = location;

		Log.d (AndroidSensors.TAG, "Updated last known location.");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * android.location.LocationListener#onProviderDisabled(java.lang.String)
	 */
	public void onProviderDisabled (String provider)
	{
		// TODO Auto-generated method stub
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * android.location.LocationListener#onProviderEnabled(java.lang.String)
	 */
	public void onProviderEnabled (String provider)
	{
		// TODO Auto-generated method stub
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.location.LocationListener#onStatusChanged(java.lang.String,
	 * int, android.os.Bundle)
	 */
	public void onStatusChanged (String provider, int status, Bundle extras)
	{
		// TODO Auto-generated method stub
	}

	/** @return The user's last known location. */
	Location getLastKnownLocation ()
	{
		return lastKnownLocation;
	}
}
